home *** CD-ROM | disk | FTP | other *** search
- Path: wallias.eda.com!news
- From: risk@eda.com
- Newsgroups: comp.lang.c
- Subject: Question: Linking a Turbo assembler .OBJ with a C .obj in Borland v4.0
- Date: 2 Feb 1996 19:22:27 GMT
- Organization: EDA Instruments Inc, Toronto, Canada
- Message-ID: <4eto9j$893@wallias.eda.com>
- NNTP-Posting-Host: risk.eda.com
- Mime-Version: 1.0
- Content-Type: multipart/mixed;
- boundary="-------------------------------66331716921094"
- X-Mailer: Mozilla 1.2N (Windows; I; 16bit)
-
- This is a multi-part message in MIME format.
-
- ---------------------------------66331716921094
- Content-Transfer-Encoding: 7bit
- Content-Type: text/plain; charset=us-ascii
-
- Question: When I try to link the obj's in the project, I get a linker
- (TLINK) warning message saying
-
- "Linker Error: Undefined symbol _fetch in module MAIN.C"
-
- I've tried using various methods of prototyping (including 'extern "c"'
- which didn't work -- I'm not using any C++ compiler functionality).
-
- The ASM file is one of two nodes for the executable in the project IDE.
-
- What do I have to do to get it to link?
-
- ---------------------------------66331716921094
- Content-Transfer-Encoding: 7bit
- Content-Type: text/plain
-
- ; Medium model C - callable assembler function to crc data from the
- ; the printer port.
- ;
- ; Function prototype:
- ; extern unsigned short int Fetch(char * near,
- ; char * near );
- ;
- ; Input:
- ; char * near ; pointer to the memory buffer <16kbytes
- ;
- ; Returns:
- ; CRC value of data calculated in and returned in ax
- ;
- .MODEL medium ;
- .CODE ;
- PUBLIC _crc ;
- _crc PROC ;
- push bp ;stack pointer
- mov bp,sp ;index stuff from bp instead of sp
- push si ;stack data index
- push di ;stack CRC table index
- push ds ;stack data segment pointer
- lds si,[bp+4] ;load the memory pointer into ds:si
- les bx,[bp+6] ;load the CRC table pointer into es:bx
- ;
- ;Do a CRC on the data passed. ;
- ;ax contains the CRC value ;
- mov cx,4000h ;crc 16 kbytes of memory
- xor ax,ax ;clear ax (start crc at 0)
- crc_loop: ;
- mov bl,ds:[si] ;read next byte of memory
- xor bx,ax ;caculate CRC look up value
- and bx,00ffh ;ensure lookup value <255
- shl bx,01h ;multiply by two for word size
- mov bx,es:[bx] ;read the table value
- shr ax,08h ;shift crc value down
- xor ax,bx ;calculate new crc value
- loop crc_loop ;
- pop ds ;
- pop di ;
- pop si ;
- pop bp ;
- ret ;
- _crc ENDP ;
- END ;
-
-